<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of executeDASCommand</title>
  <meta name="keywords" content="executeDASCommand">
  <meta name="description" content="EXECUTEDASCOMMAND is the DAS Version 1.53 API.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../index.html">Home</a> &gt;  <a href="index.html">code</a> &gt; executeDASCommand.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../index.html"><img alt="<" border="0" src="../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for code&nbsp;<img alt=">" border="0" src="../right.png"></a></td></tr></table>-->

<h1>executeDASCommand
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>EXECUTEDASCOMMAND is the DAS Version 1.53 API.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function [xmlStruct, xml,status,dasUrl] = executeDASCommand(serverURL,varargin) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> EXECUTEDASCOMMAND is the DAS Version 1.53 API.

 EXECUTEDASCOMMAND executes a DAS query to the specified DAS service. For a full description of
 the commands, including formats of DAS commands in this
 version check out http://www.biodas.org/documents/spec.html.
 
 EXECUTEDASCOMMAND has a very flexible input format to embrace the whole
 set of DAS commands and their arguments. See EXAMPLES below to get to know how to
 call an specific DAS cabapiblity and pass the needed arguments for
 running it. Each capability has its own set of arguments.

EXAMPLES: 

 DSN, ENTRY_POINTS, STYLESHEET queries - just provide the url for the DAS
 service and the command, without arguments. Timeout defines the maximum
 amount of time allowed for the server to return the query, and can be
 specified for all queries (in miliseconds).
 
 eg. Finding out data sources available in a DAS server
 [xmlS, xml] =
 executeDasCommand('http://www.ebi.ac.uk/das-srv/uniprot/das', ...
'command','dsn','timeout', 15000)
     
 eg. Finding out entry_points in the specified DAS service
 [xmlS, xml]=
 executeDasCommand('http://www.ebi.ac.uk/das-srv/uniprot/das','command', ...
 'entry_points', 'DSN', 'uniprot-goa')
     
 
 DNA, SEQUENCE, TYPES, FEATURES, STRUCTURE, INTERACTION and ALIGNMENT queries - provide the url for DAS service,
 command, and segment definitions. Segment can be eiher a fragment in the
 referenced sequence or an ID that identifies the segment.
 
 eg. Retrieving DNA sequence
[xmlS, xml] = executeDASCommand('http://genome.cse.ucsc.edu/cgi-bin/das','command', 'dna', 'DSN', 'hg16','chrom','6','start','37429768' ...
, 'stop', '37470491')
 
 eg. Retrieving AA sequence with SEQUENCE command
[xmlS, xml] =
executeDASCommand('http://www.ebi.ac.uk/das-srv/uniprot/das','command', ...
'sequence', 'DSN', 'uniprot','segment','A4_HUMAN')
 
 eg. Get the features annotated for the sequence with TYPES command
[xmlS, xml] =
executeDASCommand('http://www.ebi.ac.uk/das-srv/uniprot/das','command', ...
'types', 'DSN', 'uniprot','segment','A4_HUMAN')
     
 eg. Get the 3D structure of a protein using STRUCTURE command
[xmlS, xml] =
executeDASCommand('http://das.sanger.ac.uk/das','command', ...
'structure', 'DSN', 'structure','segment','1a4a')
     
 eg. Retrieve pairwise/multiple alignment with ALIGNMENT command
[xmlS, xml] =
executeDASCommand('http://das.sanger.ac.uk/das','command', ...
'alignment', 'DSN', 'msdpdbsp','segment','P50225')
     
 eg. Retrieve ptn-ptn interactions with INTERACTION command
[xmlS, xml] =
executeDASCommand('http://dasmi.bioinf.mpi-inf.mpg.de/das','command', ...
'interaction', 'DSN', 'sanger','segment','10526')
     
     
 
 FEATURES query - provide the url for DAS service,
 command, segment definitions and the list of features (optional). Segment can be eiher a fragment in the
 referenced sequence or an ID that identifies the segment.
 
 Get all features description for the A4_HUMAN protein
 [xmlS, xml] =
 executeDASCommand('http://www.ebi.ac.uk/das-srv/uniprot/das','command', ...
 'features', 'DSN', 'uniprot','segment','A4_HUMAN')
 
 SPECIFY the full url for the query
 [xmlS, xml, status] = executeDASCommand('empty','queryURL',url)

 See also <a href="searchDASRegistry.html" class="code" title="function [xmlStruct, xml,status] = searchDASRegistry(varargin)">SEARCHDASREGISTRY</a>

   DASMiner: DAS library and browser for Matlab.
   Diogo Veiga, March 2008.</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>	READDASURL attempts to read the DAS URL within the specified timeout</li></ul>
This function is called by:
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="das_gui.html" class="code" title="function varargout = das_gui(varargin)">das_gui</a>	DAS_GUI main GUI of DASMiner Browser</li></ul>
<!-- crossreference -->

<h2><a name="_subfunctions"></a>SUBFUNCTIONS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<ul style="list-style-image:url(../matlabicon.gif)">
<li><a href="#_sub1" class="code">function [res] = isStrNumber(x)</a></li><li><a href="#_sub2" class="code">function [res] = isValidCommand(x)</a></li></ul>
<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [xmlStruct, xml,status,dasUrl] = executeDASCommand(serverURL,varargin)</a>
0002 <span class="comment">% EXECUTEDASCOMMAND is the DAS Version 1.53 API.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">% EXECUTEDASCOMMAND executes a DAS query to the specified DAS service. For a full description of</span>
0005 <span class="comment">% the commands, including formats of DAS commands in this</span>
0006 <span class="comment">% version check out http://www.biodas.org/documents/spec.html.</span>
0007 <span class="comment">%</span>
0008 <span class="comment">% EXECUTEDASCOMMAND has a very flexible input format to embrace the whole</span>
0009 <span class="comment">% set of DAS commands and their arguments. See EXAMPLES below to get to know how to</span>
0010 <span class="comment">% call an specific DAS cabapiblity and pass the needed arguments for</span>
0011 <span class="comment">% running it. Each capability has its own set of arguments.</span>
0012 <span class="comment">%</span>
0013 <span class="comment">%EXAMPLES:</span>
0014 <span class="comment">%</span>
0015 <span class="comment">% DSN, ENTRY_POINTS, STYLESHEET queries - just provide the url for the DAS</span>
0016 <span class="comment">% service and the command, without arguments. Timeout defines the maximum</span>
0017 <span class="comment">% amount of time allowed for the server to return the query, and can be</span>
0018 <span class="comment">% specified for all queries (in miliseconds).</span>
0019 <span class="comment">%</span>
0020     <span class="comment">% eg. Finding out data sources available in a DAS server</span>
0021     <span class="comment">% [xmlS, xml] =</span>
0022     <span class="comment">% executeDasCommand('http://www.ebi.ac.uk/das-srv/uniprot/das', ...</span>
0023     <span class="comment">%'command','dsn','timeout', 15000)</span>
0024 <span class="comment">%</span>
0025     <span class="comment">% eg. Finding out entry_points in the specified DAS service</span>
0026     <span class="comment">% [xmlS, xml]=</span>
0027     <span class="comment">% executeDasCommand('http://www.ebi.ac.uk/das-srv/uniprot/das','command', ...</span>
0028     <span class="comment">% 'entry_points', 'DSN', 'uniprot-goa')</span>
0029 <span class="comment">%</span>
0030 <span class="comment">%</span>
0031 <span class="comment">% DNA, SEQUENCE, TYPES, FEATURES, STRUCTURE, INTERACTION and ALIGNMENT queries - provide the url for DAS service,</span>
0032 <span class="comment">% command, and segment definitions. Segment can be eiher a fragment in the</span>
0033 <span class="comment">% referenced sequence or an ID that identifies the segment.</span>
0034 <span class="comment">%</span>
0035     <span class="comment">% eg. Retrieving DNA sequence</span>
0036     <span class="comment">%[xmlS, xml] = executeDASCommand('http://genome.cse.ucsc.edu/cgi-bin/das','command', 'dna', 'DSN', 'hg16','chrom','6','start','37429768' ...</span>
0037     <span class="comment">%, 'stop', '37470491')</span>
0038 <span class="comment">%</span>
0039     <span class="comment">% eg. Retrieving AA sequence with SEQUENCE command</span>
0040     <span class="comment">%[xmlS, xml] =</span>
0041     <span class="comment">%executeDASCommand('http://www.ebi.ac.uk/das-srv/uniprot/das','command', ...</span>
0042     <span class="comment">%'sequence', 'DSN', 'uniprot','segment','A4_HUMAN')</span>
0043 <span class="comment">%</span>
0044     <span class="comment">% eg. Get the features annotated for the sequence with TYPES command</span>
0045     <span class="comment">%[xmlS, xml] =</span>
0046     <span class="comment">%executeDASCommand('http://www.ebi.ac.uk/das-srv/uniprot/das','command', ...</span>
0047     <span class="comment">%'types', 'DSN', 'uniprot','segment','A4_HUMAN')</span>
0048 <span class="comment">%</span>
0049     <span class="comment">% eg. Get the 3D structure of a protein using STRUCTURE command</span>
0050     <span class="comment">%[xmlS, xml] =</span>
0051     <span class="comment">%executeDASCommand('http://das.sanger.ac.uk/das','command', ...</span>
0052     <span class="comment">%'structure', 'DSN', 'structure','segment','1a4a')</span>
0053 <span class="comment">%</span>
0054     <span class="comment">% eg. Retrieve pairwise/multiple alignment with ALIGNMENT command</span>
0055     <span class="comment">%[xmlS, xml] =</span>
0056     <span class="comment">%executeDASCommand('http://das.sanger.ac.uk/das','command', ...</span>
0057     <span class="comment">%'alignment', 'DSN', 'msdpdbsp','segment','P50225')</span>
0058 <span class="comment">%</span>
0059     <span class="comment">% eg. Retrieve ptn-ptn interactions with INTERACTION command</span>
0060     <span class="comment">%[xmlS, xml] =</span>
0061     <span class="comment">%executeDASCommand('http://dasmi.bioinf.mpi-inf.mpg.de/das','command', ...</span>
0062     <span class="comment">%'interaction', 'DSN', 'sanger','segment','10526')</span>
0063 <span class="comment">%</span>
0064 <span class="comment">%</span>
0065 <span class="comment">%</span>
0066 <span class="comment">% FEATURES query - provide the url for DAS service,</span>
0067 <span class="comment">% command, segment definitions and the list of features (optional). Segment can be eiher a fragment in the</span>
0068 <span class="comment">% referenced sequence or an ID that identifies the segment.</span>
0069 <span class="comment">%</span>
0070     <span class="comment">% Get all features description for the A4_HUMAN protein</span>
0071     <span class="comment">% [xmlS, xml] =</span>
0072     <span class="comment">% executeDASCommand('http://www.ebi.ac.uk/das-srv/uniprot/das','command', ...</span>
0073     <span class="comment">% 'features', 'DSN', 'uniprot','segment','A4_HUMAN')</span>
0074 <span class="comment">%</span>
0075 <span class="comment">% SPECIFY the full url for the query</span>
0076 <span class="comment">% [xmlS, xml, status] = executeDASCommand('empty','queryURL',url)</span>
0077 <span class="comment">%</span>
0078 <span class="comment">% See also SEARCHDASREGISTRY</span>
0079 <span class="comment">%</span>
0080 <span class="comment">%   DASMiner: DAS library and browser for Matlab.</span>
0081 <span class="comment">%   Diogo Veiga, March 2008.</span>
0082 
0083 p = inputParser;   <span class="comment">% Create an instance of the class.</span>
0084 
0085 p.addRequired(<span class="string">'serverURL'</span>, @ischar); <span class="comment">%check if it is in the registry</span>
0086 p.addParamValue(<span class="string">'command'</span>, <span class="string">''</span>, @(x) <a href="#_sub2" class="code" title="subfunction [res] = isValidCommand(x)">isValidCommand</a>(x) );
0087 p.addParamValue(<span class="string">'queryURL'</span>, <span class="string">''</span>, @ischar); <span class="comment">%write fction to check if its a valid url</span>
0088 p.addParamValue(<span class="string">'DSN'</span>, <span class="string">''</span>, @ischar);
0089 p.addParamValue(<span class="string">'segment'</span>, <span class="string">''</span>, @ischar); <span class="comment">%check if it is a valid ID?</span>
0090 p.addParamValue(<span class="string">'chrom'</span>, <span class="string">''</span>, <span class="keyword">...</span>
0091      @(x) isinteger(x) || <a href="#_sub1" class="code" title="subfunction [res] = isStrNumber(x)">isStrNumber</a>(x));
0092 p.addParamValue(<span class="string">'start'</span>, <span class="string">''</span>, <span class="keyword">...</span>
0093      @(x) isinteger(x) || <a href="#_sub1" class="code" title="subfunction [res] = isStrNumber(x)">isStrNumber</a>(x) ); <span class="comment">%check if string corresponds to a double</span>
0094 p.addParamValue(<span class="string">'stop'</span>, <span class="string">''</span>);
0095 p.addParamValue(<span class="string">'featuresList'</span>, <span class="string">''</span>, @iscellstr);
0096 p.addParamValue(<span class="string">'timeout'</span>, 30000, @isnumeric); <span class="comment">%time in miliseconds</span>
0097 
0098 p.KeepUnmatched = true;
0099 p.FunctionName = <span class="string">'EXECUTEDASCOMMAND'</span>;
0100 p.parse(serverURL, varargin{:});
0101 
0102 
0103 <span class="keyword">if</span> (strcmp(p.Results.command,<span class="string">''</span>) &amp;&amp; strcmp(p.Results.queryURL,<span class="string">''</span>))
0104     error(<span class="string">'No command or query URL defined.'</span>);
0105 <span class="keyword">end</span>
0106 
0107 <span class="keyword">if</span> (strcmp(serverURL(end),<span class="string">'/'</span>))
0108     serverURL = serverURL(1:end-1);
0109 <span class="keyword">end</span>
0110 
0111 <span class="keyword">if</span> (strcmp(p.Results.command,<span class="string">'dsn'</span>))
0112     dasUrl = strcat(serverURL, <span class="string">'/'</span>, p.Results.command); 
0113 <span class="keyword">end</span>
0114 
0115 <span class="keyword">if</span> (isempty(p.Results.command))
0116     dasUrl = p.Results.queryURL; 
0117 <span class="keyword">end</span>
0118 
0119 <span class="keyword">if</span> (any(strcmpi(p.Results.command,{<span class="string">'entry_points'</span>,<span class="string">'stylesheet'</span>})) ) <span class="comment">%Requires DSN</span>
0120     <span class="keyword">if</span> (strcmp(p.Results.DSN,<span class="string">''</span>))
0121         error(<span class="string">'Query entry_points? needs parameter DSN'</span>);
0122     <span class="keyword">end</span>
0123     dasUrl = strcat(serverURL, <span class="string">'/'</span>, p.Results.DSN, <span class="string">'/'</span>, p.Results.command); 
0124 <span class="keyword">end</span>
0125 
0126 <span class="keyword">if</span> (any(strcmpi(p.Results.command,{<span class="string">'dna'</span>,<span class="string">'sequence'</span>,<span class="string">'types'</span>,<span class="string">'features'</span>,<span class="string">'structure'</span>,<span class="string">'alignment'</span>,<span class="string">'interaction'</span>})) ) <span class="comment">%Requires DSN and Segment definitions</span>
0127 
0128     <span class="keyword">if</span> (strcmp(p.Results.DSN,<span class="string">''</span>))
0129         error(<span class="string">'Query sequence? needs parameter DSN'</span>);
0130     <span class="keyword">end</span>
0131      
0132     <span class="keyword">if</span> (~strcmp(p.Results.segment,<span class="string">''</span>))
0133 
0134         <span class="keyword">if</span> (any(strcmpi(p.Results.command,{<span class="string">'structure'</span>,<span class="string">'alignment'</span>})))
0135             dasUrl = strcat(serverURL, <span class="string">'/'</span>, p.Results.DSN, <span class="string">'/'</span>, p.Results.command, <span class="string">'?query='</span>, p.Results.segment);
0136         <span class="keyword">elseif</span> (strcmp(p.Results.command,<span class="string">'interaction'</span>)) 
0137             dasUrl = strcat(serverURL, <span class="string">'/'</span>, p.Results.DSN, <span class="string">'/'</span>, p.Results.command, <span class="string">'?interactor='</span>, p.Results.segment);
0138         <span class="keyword">else</span>
0139             dasUrl = strcat(serverURL, <span class="string">'/'</span>, p.Results.DSN, <span class="string">'/'</span>, p.Results.command, <span class="string">'?segment='</span>, p.Results.segment);
0140         <span class="keyword">end</span>
0141 
0142     <span class="keyword">else</span>
0143         <span class="keyword">if</span> (any(strcmpi(p.Results.command,{<span class="string">'structure'</span>,<span class="string">'alignment'</span>,<span class="string">'interaction'</span>})))
0144             error(<span class="string">'Query %s? needs parameter segment.'</span>,p.Results.command);
0145         <span class="keyword">end</span>
0146                 
0147         <span class="keyword">if</span> ( strcmp(p.Results.chrom,<span class="string">''</span>) || strcmp(p.Results.start,<span class="string">''</span>) || strcmp(p.Results,<span class="string">''</span>)  )
0148             error(<span class="string">'Query dna? needs parameters chrom, start, stop.'</span>);
0149         <span class="keyword">else</span>
0150             dasUrl = strcat(serverURL, <span class="string">'/'</span>, p.Results.DSN, <span class="string">'/'</span>, p.Results.command, <span class="string">'?segment='</span>, p.Results.chrom, <span class="keyword">...</span>
0151                 <span class="string">':'</span>, p.Results.start, <span class="string">','</span>, p.Results.stop);
0152         <span class="keyword">end</span>
0153     <span class="keyword">end</span>
0154 
0155     <span class="keyword">if</span> ((~isempty(p.Results.featuresList)) &amp;&amp; (strcmp(p.Results.command,<span class="string">'features'</span>)) )
0156 
0157         <span class="keyword">for</span> i=1:size(p.Results.featuresList,2)
0158             dasUrl = strcat(dasUrl,<span class="string">';type='</span>,p.Results.featuresList{1,i});
0159         <span class="keyword">end</span>
0160         dasUrl = strcat(dasUrl,<span class="string">';categoryze=yes'</span>);
0161     <span class="keyword">end</span>
0162      
0163 <span class="keyword">end</span>
0164 [xmlStruct, xml, status] = <a href="readDASURL.html" class="code" title="function [xmlStruct, xml, status] = readDASURL(dasUrl,timeout)">readDASURL</a>(dasUrl,p.Results.timeout);
0165     
0166    
0167 <span class="comment">% ARGUMENT VALIDATION FUNCTIONS</span>
0168 <a name="_sub1" href="#_subfunctions" class="code">function [res] = isStrNumber(x)</a>
0169 
0170 [t,res] = str2num(x);
0171 
0172 <a name="_sub2" href="#_subfunctions" class="code">function [res] = isValidCommand(x)</a>
0173 
0174 res = any(strcmpi(x,{<span class="string">'dsn'</span>,<span class="string">'entry_points'</span>, <span class="string">'dna'</span>, <span class="string">'sequence'</span>, <span class="string">'types'</span>, <span class="string">'features'</span>, <span class="string">'stylesheet'</span>, <span class="string">'structure'</span>, <span class="string">'alignment'</span>,<span class="string">'interaction'</span>}));
0175 
0176</pre></div>
<hr><address>Generated on Tue 17-Feb-2009 16:59:45 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>